package com.youdianda.controller;

import com.youdianda.dto.SysUserInsertDTO;
import com.youdianda.dto.SysUserPageDTO;
import com.youdianda.dto.UserUpdateDTO;
import com.youdianda.result.PageResult;
import com.youdianda.result.Result;
import com.youdianda.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sys_user")
public class SysUserController1 {
    @Autowired
    private ISysUserService iSysUserService;


    /**
     * 用户列表 分页查询
     * @param dto
     * @return
     */
    @GetMapping("/list")
    public Result userList(SysUserPageDTO dto){return iSysUserService.userList(dto);}


    /**
     * 根据id删除用户 管理员删除
     * @param id
     * @return
     */
    @GetMapping("/del")
    public Result userDel(String id){return iSysUserService.userDel(id);}

    /**
     * 新增员工
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public Result userAdd(@RequestBody SysUserInsertDTO dto){return iSysUserService.userAdd(dto);}

    /**
     * 根据id查询用户 回显
     * @param id
     * @return
     */
    @GetMapping("/rowInfo")
    public Result userRowInfo(String id){return iSysUserService.userRowInfo(id);}

    /**
     * 根据信息修改数据
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public Result userUpdate(@RequestBody UserUpdateDTO dto){return iSysUserService.userUpdate(dto);}
}
